<?php

class HCommon {
	/**
	 * Rewrite URL, return the rewritten url based on RULES
	 * 
	 * RULES will be defined later
	 *
	 * @param string $page
	 * @param array() $params
	 */
	public static function navigateUrl($page, $params) {
		if ($params == null) {
			return HOST_NAME.'index.php?p='.$page;
		}
		else {
			$result = 'index.php?p='.$page;
			foreach ($params as $key=>$value) {
				$result .= '&'.$key.'='.$value;
			}
			return HOST_NAME.$result;
		}
	}
	
	public static function resolveUrl($full_url) {
		return $full_url;
	}
	
	/**
	 * Avoid SQL Injection and Cross-site Attack
	 *
	 * @param string $string
	 * @return clean string
	 */
	public static function xss($string) {
		$string = stripslashes($string);
		$string = strip_tags($string);
		return $string;
	}
}